package org.linlinjava.litemall.admin.web.order_manage;

import org.linlinjava.litemall.admin.form.*;
import org.linlinjava.litemall.admin.service.order_manage.AgedmallShopWebPageService;
import org.linlinjava.litemall.db.domain.AgedmallShopWebPageDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Controller
@RequestMapping("/shop/webpage")
public class AgedmallShopWebPageViewController {

    @Autowired
    private AgedmallShopWebPageService agedmallShopWebPageService;

    @RequestMapping("view/pid/{pid}/key/{key}")
    public String who(Model model, @PathVariable("pid") String pid, @PathVariable("key") String key) {
        AgedmallShopWebPageDetail shopWebPageDetail = agedmallShopWebPageService.view(pid, key);
        if (shopWebPageDetail == null) {
            return "error-404";
        }
        model.addAttribute("title", shopWebPageDetail.getTitle());
        model.addAttribute("html", shopWebPageDetail.getHtml());
        model.addAttribute("seoDescription", shopWebPageDetail.getSeoDescription());
        model.addAttribute("seoKeywords", shopWebPageDetail.getSeoKeywords());
        return "shop-web-page";
    }

}
